#define _CRT_SECURE_NO_WARNINGS 1
#include "string.h"

namespace wusaqi
{
	void test01()
	{
		string s1;
		cout << s1.c_str() << endl;
		string s2("abcdef");
		cout << s2.c_str() << endl;
		for (int i = 0; i < s2.size(); i++)
		{
			s2[i]++;
		}
		cout << s2.c_str() << endl;

		for (auto& e : s2)
		{
			cout << e << " ";
		}
		cout << endl;

		string::iterator it1 = s2.begin();
		while (it1 != s2.end())
		{
			cout << (*it1) << " ";
			it1++;
		}
	}

	void test02()
	{
		string s1("good morning");
		s1.push_back('f');
		cout << s1.c_str() << endl;
		s1.append(" wusaqi");
		cout << s1.c_str() << endl;
		s1 += "666888";
		cout << s1.c_str() << endl;
		s1 += 'x';
		cout << s1.c_str() << endl;
		s1 += '\0';
		s1 += '\0';
		s1 += 'f';
		cout << s1.c_str() << endl;
		cout << s1 << endl;
		s1 += " yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
		cout << s1 << endl;
	}

	void test03()
	{
		string s1("good morning");
		cout << s1 << endl;
		cout << s1.find('d') << endl;
		//s1.erase(1, 7);
		//cout << s1 << endl;
		//string s2("good morning");
		//s2.erase(7);
		//cout << s2 << endl;
		//string s3("good morning");
		//s3.erase(7, 7);
		//cout << s3 << endl;
		//s1.insert(2, 'x');
		//cout << s1 << endl;
		//s1.insert(5, "xyz");
		//cout << s1 << endl;
		//s1.insert(0, "wusaqi ");
		//cout << s1 << endl;
	}


	void split_url(string s)
	{
		size_t i1 = s.find(':');
		if (i1 != string::npos)
		{
			cout << s.substr(0, i1) << endl;
		}
		size_t i2 = i1 + 3;
		size_t i3 = s.find('/', i2);
		if (i3 != string::npos)
		{
			cout << s.substr(i2, i3 - i2) << endl;
			cout << s.substr(i3 + 1) << endl;;
		}
		cout << endl;
	}

	void test04()
	{
		string url1("https://legacy.cplusplus.com/reference/string/string/substr/");
		string url2("https://editor.csdn.net/md?articleId=147858513");
		split_url(url1);
		split_url(url2);
		//string str("good morning");
		//cout << str.substr(5) << endl;
	}

	void test05()
	{
		//string s1("good ");
		//string s2("good");
		//cout << (s1 == s2) << endl;
		//cout << (s1 != s2) << endl;
		//cout << (s1 < s2) << endl;
		//cout << (s1 > s2) << endl;
		//cout << (s1 <= s2) << endl;
		//cout << (s1 >= s2) << endl;
		string s1("hello");
		string s2("good");
		cout << s1 << " " << s2 << endl;
		cin >> s1 >> s2;
		cout << s1 << " " << s2 << endl;
	}
}

int main()
{
	//wusaqi::test01();
	//wusaqi::test02();
	//wusaqi::test03();
	//wusaqi::test04();
	wusaqi::test05();
	return 0;
}